<template>
  <div>
    <img :src="QRImgUrl"/>
  </div>
</template>
<script>
import QRCode from 'qrcode';
export default {
  name: '',
  data () {
    return {
        QRImgUrl: "http://www.baidu.com",
        QRlink: "www.baidu.com"
    };
  },
  created() {
    this.getQRcode();
  },
  methods: {
    getQRcode(){
      let opts = {
       errorCorrectionLevel: "L",//容错级别
       type: "image/jpeg",//生成的二维码类型
       quality: 0.3,//二维码质量
       margin: 5,//二维码留白边距
       width: 256,//宽
       height: 256,//高
       text: "太阳出来我爬山坡",//二维码内容
       color: {
            dark: "#fff",//前景色
            light: "#000"//背景色
              }
	    };
  		QRCode.toDataURL(this.QRlink, opts, (err, url) => {
        if (err) throw err
          this.QRImgUrl= url
        })
  	}
  },
}
</script>
<style scoped>

</style>